package dobest.ray.com.jiongjiong.activity.login.dataInport;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;

import dobest.ray.com.jiongjiong.R;
import dobest.ray.com.jiongjiong.activity.BaseActivity;
import dobest.ray.com.jiongjiong.views.DatePickerDialog;
import dobest.ray.com.jiongjiong.views.NavigationBar;

/**
 * Created by Ray on 2016/4/26.
 * https://github.com/ray0807
 * 导入学生信息
 */
public class ImportChildDataAcitivty extends BaseActivity implements View.OnClickListener {

    private CheckBox chk_female;
    private CheckBox chk_male;
    private ImageView iv_choose_date;
    private TextView tv_show_birthday;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_import_child_data);
        findViews();
        init();
        addListeners();
    }

    @Override
    public void findViews() {
        navi = (NavigationBar) findViewById(R.id.navi);
        navi.setTitle("导入数据");
        navi.setTextRight("下一步", this);
        navi.setTextRightColor(getResources().getColor(R.color.white));
        chk_female = (CheckBox) findViewById(R.id.chk_female);
        chk_male = (CheckBox) findViewById(R.id.chk_male);
        iv_choose_date = (ImageView) findViewById(R.id.iv_choose_date);
        tv_show_birthday = (TextView) findViewById(R.id.tv_show_birthday);
    }

    @Override
    public void init() {

    }

    @Override
    public void addListeners() {
        chk_female.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    chk_male.setChecked(false);
                }
            }
        });
        chk_male.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    chk_female.setChecked(false);
                }
            }
        });
        iv_choose_date.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        Intent it = null;
        switch (v.getId()) {

            case R.id.ll_text_right:
                it = new Intent(this, ShowImportChildDataActivity.class);
                break;
            case R.id.iv_choose_date:
                DatePickerDialog dialog = new DatePickerDialog(this);
                dialog.setComfirmListener(new DatePickerDialog.DateCallback() {
                    @Override
                    public void backDate(String date) {
                        tv_show_birthday.setText(date);
                    }
                });
                dialog.show();
                break;
        }
        if (it != null) {
            startActivity(it);
        }
    }
}
